home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / viewers / polyview / polyvw31.lha / Polyview3.1 / new / pvevent.c < prev    next >
C/C++ Source or Header  |  1993-06-23  |  5KB  |  129 lines

  1. /*****************************************************************************
  2.  * NCSA Polyview 3.0                                                         *
  3.  *                                                                           *
  4.  * Version 3 changes and additions by Marc Andreessen.                       *
  5.  * Version 2 by Brian Calvert.                                               *
  6.  *                                                                           *
  7.  * Software Development Group                                                *
  8.  * National Center for Supercomputing Applications                           *
  9.  * University of Illinois at Urbana-Champaign                                *
  10.  *                                                                           *
  11.  * This is BETA release software.  As such it may contain software bugs and  *
  12.  * exhibit inconsistencies.                                                  *
  13.  *                                                                           *
  14.  * Please send bug reports to polyview@ncsa.uiuc.edu.                        *
  15.  *                                                                           *
  16.  * Copyright (c) 1992 The Board of Trustees of the University of Illinois.   *
  17.  *                                                                           *
  18.  * Permission to use, copy, and modify this software and its                 *
  19.  * documentation for educational, research, and non-profit purposes is       *
  20.  * hereby granted, provided that the above copyright notice, the original    *
  21.  * authors names, and this permission notice appear in all such copies.      *
  22.  * Any distribution of this software requires the explicit and written       *
  23.  * authorization of the authors.                                             *
  24.  *                                                                           *
  25.  * The University of Illinois makes no representations about the             *
  26.  * suitability of this software for any purpose.  It is provided "as is"     *
  27.  * without warranty of any kind.                                             *
  28.  *****************************************************************************/
  29.  
  30. /* $Header: /usr3/people/gbourhis/pv3/new/RCS/pvevent.c,v 1.1 92/09/18 10:55:26 marca Exp $ */
  31.  
  32. #ifdef RCSLOG
  33. $Log:    pvevent.c,v $
  34.  * Revision 1.1  92/09/18  10:55:26  marca
  35.  * Initial revision
  36.  * 
  37. #endif
  38.  
  39. #include "pv.h"
  40. #include <gl/device.h>
  41.  
  42. int init_events(state_t *state)
  43. {
  44.   /* Initialize the state variables that the event routines use. */
  45.   state->event_count = 0;
  46.   state->redraw_count = 0;
  47.   
  48.   return ST_OKAY;
  49. }
  50.  
  51.  
  52. int make_window_active (state_t *state, window_t *win)
  53. {
  54.   if ((win != state->active_windows) &&
  55.       (win != NULL) && (win->type == POLYVIEW))
  56.     broadcast_msg(state, win, MSG_NEWACT, state->active_windows);
  57.  
  58.   return ST_OKAY;
  59. }
  60.  
  61.  
  62. int process_events (state_t *state)
  63. {
  64.   /* Redraw all of the windows that requested it. */
  65.   redraw_windows(state);
  66.   
  67.   return 0;
  68. }
  69.  
  70.  
  71.  
  72. int process_next_command (state_t *state)
  73. {
  74.   action_t *next;
  75.  
  76.   /* If we've flagged no-actions, then don't do anything,
  77.      else grab an action and do it. */
  78.   if (!state->no_actions)
  79.     {
  80.       /* Get the next serial action from the action list. */
  81.       /* This function also handles all of the messy details */
  82.       /* of removing old actions and updating countdowns for the actions. */
  83.       next = next_ser_action(state, state->action_head);
  84.       
  85.       if (next == NULL)
  86.         /* No action means that there's nothing to go wrong. */
  87.         return ST_OKAY;
  88.       else
  89.         {
  90.           /* Execute the action using do_action. */
  91.           return do_action(state, next);
  92.         }
  93.     }
  94.   else
  95.     {
  96.       return ST_OKAY;
  97.     }
  98. }
  99.  
  100.  
  101. int animate_windows(state_t *state)
  102. {
  103.   window_t *win;
  104.   
  105.   /* Check each window to see if it is worth animating. */
  106.   for (win = state->windows; win != NULL; win = win->next) 
  107.     {
  108.       if (((WIN_FORWARD(win) != 0)||(WIN_REVERSE(win) != 0))) 
  109.         {
  110.           /* This window is currently being animated and needs its */
  111.           /* animation variables updated. */
  112.           (win->countdown)--;
  113.           if ((win->countdown <= 0) && (win->animate_fn != NULL)) 
  114.             {
  115.               /* The window is to be updated.  Call the window's */
  116.               /* animate function to handle the details of what */
  117.               /* that means for this window type. */
  118.               (*win->animate_fn)(state, win);
  119.               win->countdown = WIN_DELAY(win);
  120.               if (WIN_FORWARD(win) > 0)
  121.                 WIN_FORWARD(win)--;
  122.               else if (WIN_REVERSE(win) > 0)
  123.                 WIN_REVERSE(win)--;
  124.             }
  125.         }
  126.     }
  127.   return ST_OKAY;
  128. }
  129.